<template>
	<view>
		<navbar title="交易统计" :isbg="false" :autoBack="true" :opacity='1'>
			
		</navbar>
		<view class="con">
			<view class="box">
				<view class="box__title" @click="getyglist">
					所有员工 <u-icon name="arrow-down-fill" size="16rpx" color="#6d6d6d"></u-icon>
				</view>
				<view v-if="details.totalPrice!==undefined">
					<view class="box__ibox">
						<view class="box__ibox__name">
							交易总金额
						</view>
						<view class="box__ibox__value">
							{{details.totalPrice.toFixed(2)}}
						</view>
						<image class="box__ibox__icon" src="/static/data/tjicon.png" mode=""></image>
					</view>
					<view class="box__ibox" style="background-color: #259ADC;">
						<view class="u-flex u-flex-y-center">
							<view class="box__ibox__name">
								今日
							</view>
							<view class="box__ibox__value">
								{{details.todayPrice.toFixed(2)}}
							</view>
						</view>
						<view class="u-flex u-flex-y-center">
							<view class="box__ibox__name">
								昨天
							</view>
							<view class="box__ibox__value">
								{{details.yesterdayPrice.toFixed(2)}}
							</view>
						</view>
						<image class="box__ibox__icon" src="/static/data/tjicon.png" mode=""></image>
					</view>
					<view class="box__ibox" style="background-color: #FD5E8E;">
						<view class="u-flex u-flex-y-center">
							<view class="box__ibox__name">
								本月
							</view>
							<view class="box__ibox__value">
								{{details.monthPrice.toFixed(2)}}
							</view>
						</view>
						<view class="u-flex u-flex-y-center">
							<view class="box__ibox__name">
								上月
							</view>
							<view class="box__ibox__value">
								{{details.lastmonthPrice.toFixed(2)}}
							</view>
						</view>
						<image class="box__ibox__icon" src="/static/data/tjicon.png" mode=""></image>
					</view>
					<view class="box__ibox" style="background-color: #EFA63F;">
						<view class="u-flex u-flex-y-center">
							<view class="box__ibox__name">
								今年
							</view>
							<view class="box__ibox__value">
								{{details.yearPrice.toFixed(2)}}
							</view>
						</view>
						<view class="u-flex u-flex-y-center">
							<view class="box__ibox__name">
								去年
							</view>
							<view class="box__ibox__value">
								{{details.lastyearPrice.toFixed(2)}}
							</view>
						</view>
						<image class="box__ibox__icon" src="/static/data/tjicon.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		<u-picker :show="show" :columns="columns" keyName='username' :loading="loading" @close='show=false' @cancel='show=false' @confirm='confirm'></u-picker>
	</view>
</template>

<script>
	import datagl from '@/api/_datagl.js'
	export default {
		data() {
			return {
				user_id:'',
				details:{},
				show:false,
				columns:[[{username:'全部员工',id:''}]],
				loading:false,
				username:'全部员工'
			};
		},
		methods:{
			async gettj(){
				let res = await datagl.getTotal({user_id:this.user_id})
				
				if(res.data.code==1){
					this.details=res.data.data
				}
			},
			async getyglist(){
				this.loading=true
				this.columns=[[{username:'全部员工',id:''}]]
				this.show=true
				let res = await datagl.getUserList()
				if(res.data.code==1){
					this.loading=false
					this.columns=[[...this.columns[0],...res.data.data]]
				}
			},
			confirm(e){
				this.username=e.value[0].username
				this.user_id=e.value[0].id
				this.show=false
				this.gettj()
			}
		},
		onLoad() {
			this.gettj()
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #F8F8F8;
	}
	.con{
		padding: 30rpx;
		.box{
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			padding: 35rpx 24rpx 30rpx 30rpx;
			&__title{
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				font-size: 28rpx;
				color: #6D6D6D;
				line-height: 28rpx;
				margin-bottom: 30rpx;
				display: flex;
				align-items: center;
			}
			&__ibox{
				height: 120rpx;
				background: #2BB97E;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				position: relative;
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				padding: 27rpx 0;
				margin-bottom: 28rpx;
				&__icon{
					width: 135rpx;
					height: 136rpx;
					position: absolute;
					top: 26rpx;
					right: 24rpx;
				}
				&__name{
					font-family: PingFang-SC, PingFang-SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #FFFFFF;
					line-height: 24rpx;
					margin-left: 30rpx;
				}
				&__value{
					font-family: DIN Next LT Pro;
					font-weight: 500;
					font-size: 48rpx;
					color: #FFFFFF;
					line-height: 48rpx;
					margin-left: 30rpx;
				}
			}
		}
	}
</style>
